import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-09-04
 * Time: 22:44
 * To BE A Better Person-2020-3-2
 */
//字节流读取数据
public class TesDemo4 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream=new FileInputStream("test2.txt");
        byte[] b=new byte[1024];
        int len=inputStream.read(b);

        String word=new String(b,0,len,"utf8");
        System.out.println(word);

    }
    public static void main1(String[] args) throws IOException {
        InputStream inputStream=new FileInputStream("test2.txt");
        while(true){
            int b=inputStream.read();
            if(b==-1){
                break;
            }
            System.out.println(b);
        }
        inputStream.close();
    }
}
